Skip to content

fix: crash on window close from double-release of shader blobs - #5

Merged
igagis-bot merged 1 commit into
mainfrom
fix-window-close-crash
Dec 2, 2026
Merged

igagis-bot merged 1 commit into
mainfrom
fix-window-close-crash

Conversation

@igagis-bot

Copy link
Copy Markdown
Contributor

Fixes the DirectX app crash on closing a new window (see cppfw/ruisapp#44).

Root cause

ruis::render::directx::context stores the HLSL shader blobs (created by D3DCompile) in a std::vector<std::unique_ptr<ID3DBlob>>.

In the destructor, each blob was explicitly Release()d, then shader_blobs.clear() ran the unique_ptr's default deleter, which called delete on the already-released (and possibly destroyed) COM objects. Closing a window triggered this teardown path, crashing the process (exit code 3221226356 / access violation).

Fix

Use a custom deleter for the shader blob vector that calls ID3DBlob::Release(), and drop the explicit release loop in the destructor. The vector's elements now release the COM object exactly once, in the correct order (pipelines first, then blobs).

Verification

Reproduced the crash on ruisapp-directx-test (create a new window via the probe, close it with WM_CLOSE):

  • before: process exits with code 3221226356
  • after: the window closes cleanly (windows_count{1}), the app stays alive
  • closing the main window exits with code 0

The context destructor explicitly Release()d each ID3DBlob and then
shader_blobs.clear() ran the unique_ptr default deleter, which called
delete on the already-released (destroyed) COM objects, crashing the
process.

Use a custom deleter for the shader blob vector that calls
ID3DBlob::Release(), and drop the explicit release loop.
@igagis-bot
igagis-bot merged commit e9ace2d into main Dec 2, 2026
8 of 12 checks passed
@igagis-bot
igagis-bot deleted the fix-window-close-crash branch December 2, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants